package thread;

//isAlive()

public class Demo8 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            for (int i = 0; i < 3; i++) {
                System.out.println("hello Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        t.start();

        //t线程生命周期结束，但是t任然存在
        while(true) {
            //结果可能输出3~4个true，主要看执行过程中随机调度线程的先后顺序
            System.out.println(t.isAlive());
            Thread.sleep(1000);
        }
    }
}
